﻿using System.Threading.Tasks;

namespace DotNetStar.OpenSDK.WeChat
{
    using Pay;
    /// <summary>
    /// 微信支付平台的扩展。
    /// </summary>
    public static class WeChatPayExtensions
    {
        /// <summary>
        /// 以异步的方式执行微信支付的统一下单功能。
        /// </summary>
        /// <param name="weChatPay">微信支付平台。</param>
        /// <param name="request">统一下单所需的参数。</param>
        /// <returns>统一下单的返回结果。</returns>
        public static Task<UnifiedOrderApiResponse> UnifiedOrderAsync(this WeChatPayPlatform weChatPay, UnifiedOrderApiRequest request)
        => ApiClient.ExecuteAsync(request);

        /// <summary>
        /// 以异步的方式执行微信支付的订单查询功能。
        /// </summary>
        /// <param name="weChatPay">微信支付平台。</param>
        /// <param name="request">订单查询所需参数。</param>
        /// <returns>订单查询的返回结果。</returns>
        public static Task<OrderQueryApIResponse> OrderQueryAsync(this WeChatPayPlatform weChatPay, OrderQueryApiRequest request)
        => ApiClient.ExecuteAsync(request);

        /// <summary>
        /// 以异步的方式执行微信支付的关闭订单功能。
        /// </summary>
        /// <param name="weChatPay">微信支付平台。</param>
        /// <param name="request">关闭订单所需参数。</param>
        /// <returns>关闭订单的返回结果。</returns>
        public static Task<WeChatPayApiResponse> CloseOrderAsync(this WeChatPayPlatform weChatPay, CloseOrderApiRequest request)
        => ApiClient.ExecuteAsync(request);

        /// <summary>
        /// 以异步的方式执行微信支付的申请退款功能。
        /// </summary>
        /// <param name="weChatPay">微信支付平台。</param>
        /// <param name="request">申请退款所需参数。</param>
        /// <returns>申请退款的返回结果。</returns>
        public static Task<RefundApiResponse> RefundAsync(this WeChatPayPlatform weChatPay, RefundApiRequest request)
        => ApiClient.ExecuteAsync(request);

        /// <summary>
        /// 以异步的方式执行微信支付的退款查询功能。
        /// </summary>
        /// <param name="weChatPay">微信支付平台。</param>
        /// <param name="request">退款查询所需参数。</param>
        /// <returns>退款查询的返回结果。</returns>
        public static Task<RefundQueryApiResponse> RefundQueryAsync(this WeChatPayPlatform weChatPay, RefundQueryApiRequest request)
        => ApiClient.ExecuteAsync(request);
    }
}
